package com.backstage.controller;

import com.backstage.pojo.Chatroom;
import com.backstage.pojo.User;
import com.backstage.service.ChatroomService;
import com.backstage.utils.PageBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
@RequestMapping(value = "/admin")
public class chatroom_list {
    @Autowired
    ChatroomService chatroomService;

    @RequestMapping(value = "/chatroom_list", method = RequestMethod.GET)
    public String chatroomlist(
        @RequestParam(required = false, defaultValue = "1") int page,
        @RequestParam(required = false, defaultValue = "10") int pageSize,
        @RequestParam(required = false, defaultValue = " ") String keyWord,
        Model model
    ){
        PageBean<Chatroom> pageBean = chatroomService.selectChatroomList(page, pageSize, keyWord);
        model.addAttribute("list",pageBean.getList());
        model.addAttribute("pager",pageBean.getPageBeanObj());
        return "/admin/chatroom_list";
    }

}
